package com.horizon.wxapp.controller;

import com.horizon.wxapp.service.GoodService;
import com.horizon.wxapp.vo.GoodVo;
import com.horizon.wxapp.vo.params.PageParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("goods")
public class GoodController {

    @Autowired
    private GoodService goodService;

    @RequestMapping
    public List<GoodVo> listGood(PageParams pageParams) {
        return goodService.listGood(pageParams);
    }

    @RequestMapping("{id}")
    public GoodVo getGoodById(@PathVariable Integer id) {
        return goodService.getGoodById(id);
    }

    @RequestMapping("/title")
    public List<GoodVo> getGoodByTitle(String title) {
        return goodService.getGoodByTitle(title);
    }

    @RequestMapping("category")
    public List<GoodVo> getGoodByCategoryId(Integer categoryId) {
        return goodService.getGoodByCategoryId(categoryId);
    }
}
